home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Special 16 / AMIGAplus Sonderheft 16 (1998)(ICP)(DE)[!].iso / pd / anwendungen / xpk_source / e / none / none.e < prev   
Text File  |  1998-08-27  |  5KB  |  248 lines

  1.  
  2. /*
  3. **
  4. ** xpkNONE.library
  5. **
  6. ** This is just an exaple how to create an xpk-library, the library
  7. ** itself are useless.
  8. **
  9. */
  10.  
  11.  
  12. OPT PREPROCESS
  13.  
  14. MODULE '*none_xpkrev'
  15.  
  16. MODULE 'xpk/xpk', 'xpk/xpksub'
  17.  
  18.  
  19.  
  20. /*****************************  CONSTANTS  ********************************/
  21.  
  22.  
  23. #define LIB_AUTHOR      'Torgil Svensson'
  24.  
  25. CONST MASTER_VERSION  = 0 -> required xpkmaster version
  26.  
  27.  
  28. /*-------------------  xpk library setup  --------------------*/
  29.  
  30.  
  31. CONST LIB_FLAGS = XPKIF_PK_CHUNK OR   -> chunk packing
  32.                   XPKIF_UP_CHUNK      -> chunk unpacking
  33.  
  34. CONST DEF_MODE  = 100     -> default mode number
  35.  
  36.  
  37.  
  38. /*--------------------  memory / buffers  --------------------*/
  39.  
  40.  
  41. CONST MAX_IN_CHUNK = $7ffffff, -> max chunk size 
  42.       MIN_IN_CHUNK = 1,        -> min chunk size
  43.       DEF_IN_CHUNK = 100000    -> default packing chunk size
  44.  
  45.  
  46.  
  47. /*-------------------  strings / messages  -------------------*/
  48.  
  49.      -> (max 20 chars)
  50. #define LIB_SHORT_NAME  LIB_NAME + ' V' + LIB_VERSION + '.' + LIB_REVISION
  51.  
  52.      -> (max 30 chars)
  53. #define LIB_LONG_NAME   LIB_FULL_NAME + ' V' + LIB_VERSION + '.' + LIB_REVISION
  54.  
  55.      -> (max 70 chars)
  56. #define LIB_DESC        'This library really does no compression '+\
  57.                         'by ' + LIB_AUTHOR
  58.  
  59. #define PACK_MSG        'compressing'
  60. #define UNPACK_MSG      'decompressing'
  61. #define PACKED_MSG      'compressed'
  62. #define UNPACKED_MSG    'decompressed'
  63.  
  64.  
  65.  
  66.  
  67. /**********************  EC LIBRARY HEADER  *****************************/
  68.  
  69.  
  70. LIBRARY LIB_FULL_NAME,VERSION,REVISION,LIB_VERSTR IS
  71.  
  72.   xpksPackerInfo,   -> Get information about a packer sub-library for use
  73.   xpksPackChunk,    -> Pack a chunk of data
  74.   xpksPackFree,     -> Free buffers associated with packing process
  75.   xpksPackReset,    -> Reset all internal tables
  76.   xpksUnpackChunk,  -> Uncompress a chunk of data
  77.   xpksUnpackFree    -> Free all private data the sublib has allocated
  78.  
  79.  
  80.  
  81.  
  82.  
  83. /***********************  GLOBAL VARIABLES  *****************************/
  84.  
  85.  
  86. DEF mode1:xpkMode
  87. DEF info:xpkInfo
  88.  
  89.  
  90.  
  91.  
  92. /****************************  main()  **********************************/
  93.  
  94.  
  95. PROC main()
  96.  
  97.  
  98. /*--------------------  mode descriptors  --------------------*/
  99.  
  100. -> user selectable through the 1-100 scale in xpk
  101. -> This is a node in a linked list of modes
  102. -> Packspeed tested with A500/000 on a 460Kb file
  103.  
  104.   mode1.next          := NIL  -> next mode (NIL if last mode)
  105.   mode1.upto          := 100  -> Maximum efficiency
  106.   mode1.flags         := 0    -> Flags
  107.   mode1.packMemory    := 0    -> Extra Memory, packing
  108.   mode1.unpackMemory  := 0    -> Extra Memory, unpacking
  109.   mode1.packSpeed     := 170  -> Pack speed * 1000 bytes
  110.   mode1.unpackSpeed   := 170  -> Unpack speed * 1000 bytes
  111.   mode1.ratio         := 0    -> Ratio * 0.1%
  112.   mode1.chunkSize     := 100  -> Desired Cunk size in kb
  113.  
  114.   AstrCopy(mode1.description,'useless',10)
  115.  
  116.  
  117.  
  118. /*--------------------  xpkInfo structure  -------------------*/
  119.  
  120.  
  121.   info.xpkInfoVersion := INFO_VERSION
  122.   info.libVersion     := VERSION
  123.   info.masterVersion  := MASTER_VERSION
  124.   info.modesVersion   := MODES_VERSION 
  125.  
  126.   info.name           := LIB_SHORT_NAME
  127.   info.longName       := LIB_LONG_NAME
  128.   info.description    := LIB_DESC
  129.   info.id             := LIB_ID
  130.  
  131.   info.flags          := LIB_FLAGS
  132.  
  133.   info.maxPkInChunk   := MAX_IN_CHUNK
  134.   info.minPkInChunk   := MIN_IN_CHUNK
  135.   info.defPkInChunk   := DEF_IN_CHUNK
  136.  
  137.   info.packMsg        := PACK_MSG
  138.   info.unpackMsg      := UNPACK_MSG
  139.   info.packedMsg      := PACKED_MSG
  140.   info.unpackedMsg    := UNPACKED_MSG
  141.  
  142.   info.defMode        := DEF_MODE
  143.   info.pad            := 0      -> future use
  144.   info.modeDesc       := mode1  -> list of modes (first mode)
  145.  
  146.   info.reserved[0]    := 0
  147.   info.reserved[1]    := 0
  148.   info.reserved[2]    := 0
  149.   info.reserved[3]    := 0
  150.   info.reserved[4]    := 0
  151.   info.reserved[5]    := 0
  152.  
  153. ENDPROC
  154.  
  155.  
  156.  
  157.  
  158. /***********************  xpksPackerInfo()  *****************************/
  159.  
  160.  
  161. PROC xpksPackerInfo()
  162. ENDPROC info
  163.  
  164.  
  165.  
  166.  
  167. /***********************  xpksPackChunk()  ******************************/
  168.  
  169.  
  170. PROC xpksPackChunk(param:PTR TO xpkSubParams, dummy)
  171.  
  172.   DEF length=0,   -> number of bytes to copy
  173.       err=0       -> return value
  174.  
  175.   length := param.inLen
  176.  
  177.   -> enough space in outbuf?
  178.   IF param.outBufLen < length
  179.  
  180.     err := XPKERR_SMALLBUF
  181.     param.outLen := 0
  182.  
  183.   ELSE
  184.  
  185.     CopyMem(param.inBuf,param.outBuf,length)
  186.     param.outLen := length
  187.  
  188.   ENDIF
  189.  
  190.  
  191. ENDPROC err
  192.  
  193.  
  194.  
  195.  
  196. /************************  xpksPackFree()  ******************************/
  197.  
  198.  
  199. PROC xpksPackFree(param:PTR TO xpkSubParams, dummy)
  200. ENDPROC 0
  201.  
  202.  
  203.  
  204.  
  205. /***********************  xpksPackReset()  ******************************/
  206.  
  207.  
  208. PROC xpksPackReset(param:PTR TO xpkSubParams, dummy)
  209. ENDPROC 0
  210.  
  211.  
  212.  
  213.  
  214. /***********************  xpksUnpackChunk()  ****************************/
  215.  
  216.  
  217. PROC xpksUnpackChunk(param:PTR TO xpkSubParams, dummy)
  218.  
  219.   DEF length=0,   -> number of bytes to copy
  220.       err=0       -> return value
  221.  
  222.   length := param.inLen
  223.  
  224.   -> enough space in outbuf?
  225.   IF param.outBufLen < length
  226.  
  227.     err := XPKERR_SMALLBUF
  228.     param.outLen := 0
  229.  
  230.   ELSE
  231.  
  232.     CopyMem(param.inBuf,param.outBuf,length)
  233.     param.outLen := length
  234.  
  235.   ENDIF
  236.  
  237. ENDPROC err
  238.  
  239.  
  240.  
  241.  
  242. /***********************  xpksUnpackFree()  *****************************/
  243.  
  244.  
  245. PROC xpksUnpackFree(param:PTR TO xpkSubParams, dummy)
  246. ENDPROC 0
  247.  
  248.